package com.nsgf.library.ui.monitoring;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;

import com.kunminx.architecture.ui.page.DataBindingConfig;
import com.kunminx.architecture.ui.state.State;
import com.nsgf.library.BR;
import com.nsgf.library.R;
import com.nsgf.library.data.bean.UserInfo;
import com.nsgf.library.data.response.DataResult;
import com.nsgf.library.data.response.ResponseStatus;
import com.nsgf.library.databinding.ActivityNsgfMessageBinding;
import com.nsgf.library.databinding.ActivityNsgfMonitoringViewPageBinding;
import com.nsgf.library.domain.request.AccountRequester;
import com.nsgf.library.event.EventMsg;
import com.nsgf.library.event.RxBus;
import com.nsgf.library.magicindicator.buildins.commonnavigator.CommonNavigator;
import com.nsgf.library.magicindicator.buildins.commonnavigator.titles.badge.BadgePagerTitleView;
import com.nsgf.library.ui.adapter.XFragmentAdapter;
import com.nsgf.library.ui.page.BaseActivity;
import com.nsgf.library.ui.page.StateHolder;
import com.nsgf.library.ui.page.fragment.MessageFragment;
import com.nsgf.library.utils.PublicMethodUtils;
import com.nsgf.library.utils.ToastUtils;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

/**
 * 位移监测
 */
public class DisplacementActivity extends BaseActivity {

    StateHolder states;

    private List<Fragment> fragmentList = new ArrayList<>();

    private String[] mPageTitleList;
    private AccountRequester mAccountRequester;

    @Override
    protected void initViewModel() {

        states = getActivityScopeViewModel(StateHolder.class);
        mAccountRequester = getActivityScopeViewModel(AccountRequester.class);
    }

    @Override
    protected DataBindingConfig getDataBindingConfig() {
        return new DataBindingConfig(R.layout.activity_nsgf_monitoring_view_page, BR.vm, states);
    }

    private ActivityNsgfMonitoringViewPageBinding mBinding;

    int[] mPageTitleBadgeList = new int[]{1, 1, 1};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = (ActivityNsgfMonitoringViewPageBinding) getBinding();

        getLifecycle().addObserver(mAccountRequester);
        states.titleBar.set("位移监测");
        mBinding.viewPager.setOffscreenPageLimit(2);
        fragmentList.add(DisplacementHorizontalFragment.newInstance());
        fragmentList.add(DisplacementVerticalFragment.newInstance());
        mPageTitleList = new String[]{"水平位移", "垂直位移"};
        XFragmentAdapter adapter = new XFragmentAdapter(this, getSupportFragmentManager(), fragmentList, mPageTitleList);
        mBinding.viewPager.setAdapter(adapter);
        PublicMethodUtils.initMagicIndicator(mBinding.magicIndicator, mBinding.viewPager, mPageTitleList, this);

    }

    public static class MessageStates extends StateHolder {

        public final State<Boolean> loadingVisible = new State<>(false);
        public final State<Integer> searchVisible = new State<>(View.GONE);
        public final State<String> search = new State<>("");

    }
}
